package com.member.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.member.common.utils.DateUtils;
import com.member.shop.domain.SysBizProfileSource;
import com.member.shop.mapper.SysBizProfileSourceMapper;
import com.member.shop.service.ISysBizProfileSourceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 资料库资源Service业务层处理
 *
 * @author lixinchen
 * @date 2024-05-08
 */
@Service
public class SysBizProfileSourceServiceImpl extends ServiceImpl<SysBizProfileSourceMapper, SysBizProfileSource> implements ISysBizProfileSourceService {
    @Resource
    private SysBizProfileSourceMapper sysBizProfileSourceMapper;

    /**
     * 查询资料库资源
     *
     * @param id 资料库资源主键
     * @return 资料库资源
     */
    @Override
    public SysBizProfileSource selectSysBizProfileSourceById(Long id) {
        return sysBizProfileSourceMapper.selectById(id);
    }

    /**
     * 查询资料库资源列表
     *
     * @param sysBizProfileSource 资料库资源
     * @return 资料库资源
     */
    @Override
    public List<SysBizProfileSource> selectSysBizProfileSourceList(LambdaQueryWrapper<SysBizProfileSource> queryWrapper) {
        return sysBizProfileSourceMapper.selectList(queryWrapper);
    }

    /**
     * 新增资料库资源
     *
     * @param sysBizProfileSource 资料库资源
     * @return 结果
     */
    @Override
    public int insertSysBizProfileSource(SysBizProfileSource sysBizProfileSource) {
        sysBizProfileSource.setCreateTime(DateUtils.getNowDate());
        return sysBizProfileSourceMapper.insert(sysBizProfileSource);
    }

    /**
     * 修改资料库资源
     *
     * @param sysBizProfileSource 资料库资源
     * @return 结果
     */
    @Override
    public int updateSysBizProfileSource(SysBizProfileSource sysBizProfileSource) {
        sysBizProfileSource.setUpdateTime(DateUtils.getNowDate());
        return sysBizProfileSourceMapper.updateById(sysBizProfileSource);
    }

    /**
     * 批量删除资料库资源
     *
     * @param ids 需要删除的资料库资源主键
     * @return 结果
     */
    @Override
    public int deleteSysBizProfileSourceByIds(Long[] ids) {
        return sysBizProfileSourceMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除资料库资源信息
     *
     * @param id 资料库资源主键
     * @return 结果
     */
    @Override
    public int deleteSysBizProfileSourceById(Long id) {
        return sysBizProfileSourceMapper.deleteById(id);
    }

    @Override
    public int deleteByProfileId(Long profileId) {
        return sysBizProfileSourceMapper.deleteByProfileId(profileId);
    }

    @Override
    public List<SysBizProfileSource> queryCollectBySource(Long userId, Integer type) {
        return sysBizProfileSourceMapper.queryCollectBySource(userId, type);
    }
}
